package demo.practice.leetcode_eveyday;

public class P171 {

    public int titleToNumber(String columnTitle) {

        int[] count = new int[26];
        for (int i = 0; i < count.length; i++) {
            count[i] = i;
        }
        char[] chars = columnTitle.toCharArray();

        int res = 0;
        for (int i = chars.length - 1; i >= 0; i--) {
            int c = count[chars[i] - 'A']+1;
            for (int j = i; j < chars.length - 1; j++) {
                c *= 26;
            }
            res += c;
        }
        return res;
    }


}
